IF (NOT WIN32)
    SET (RUNTESTCASES_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/runtestcases.sh)
ELSE ()
    SET (RUNTESTCASES_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/runtestcases.bat)
ENDIF ()

FOREACH(tcdir testcases libsolv-zypptestcases)
    IF(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${tcdir}")
        FILE(GLOB dirs "${CMAKE_CURRENT_SOURCE_DIR}/${tcdir}/[_a-zA-Z0-9]*")
        FOREACH(dir ${dirs})
            IF(IS_DIRECTORY ${dir})
                FILE(RELATIVE_PATH myname "${CMAKE_CURRENT_SOURCE_DIR}/${tcdir}" ${dir})
                FILE(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/tools/testsolv" TESTSOLV_BINARY)
                FILE(TO_NATIVE_PATH "${dir}" dir)
                STRING(REPLACE \\ \\\\ dir ${dir})
                STRING(REPLACE \\ \\\\ TESTSOLV_BINARY ${TESTSOLV_BINARY})
                ADD_TEST(${myname} ${RUNTESTCASES_SCRIPT} "${TESTSOLV_BINARY}" "${dir}")
            ENDIF ()
        ENDFOREACH ()
    ENDIF ()
ENDFOREACH ()